//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    items: {
      name: '服务条款说明',
      value: '服务条款说明',
      checked: false
    },
    maskey: true
  },
  radioChange: function(e) {

    console.log('radio发生change事件，携带value值为：', e.detail.value)
  },
  changeradio: function() {
    let items = this.data.items;
    console.log(items)
    items.checked = !items.checked,
      this.setData({
        items,
      })
  },

  // 帮助弹出
  maskway: function() {
    if (this.data.maskey == true) {
      this.setData({
        maskey: false
      })
    } else if (this.data.maskey == false) {
      this.setData({
        maskey: true
      })
    }

  },

  onLoad: function(options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this
    var money = options.money
    var key = options.key
    var z_name = options.z_name
    var hospital = options.hospital
    var zid = options.zid
    var name = options.name
    that.setData({
      money: money,
      key: key,
      zid: zid,
      z_name: z_name,
      hospital: hospital,
      name: name,
      bgc: bgc
    })
    that.getYuyueinfo()
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  getYuyueinfo() {
    var that = this
    var key = that.data.key
    app.util.request({
      'url': 'entry/wxapp/Yuyue.shoushuinfo',
      data: {
        key: key
      },
      success: function(res) {
        //console.log(res.data.tishi)
        that.setData({
          tishi: res.data.tishi,
        })
      },
      fail: function(err) {
        console.log(err)
      },
    })
  },
  yuyue(e) {
    var that = this
    var checked = that.data.items.checked
    console.log(checked)
    var zid = that.data.zid
    var money = that.data.money
    var key = that.data.key
    var name = that.data.name
    if (checked) {
      wx.navigateTo({
        url: '/hyb_yl/userCommunicate/pages/preindex/pre/index?zid=' + zid + '&money=' + money + '&key=' + key + '&name=' + name,
      })
    } else {
      wx.showToast({
        title: '请先同意服务条款说明',
        icon: 'none'
      })
    }
  }
})